home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions,comp.lang.c
- Path: news.sprintlink.net!eskimo!scs
- From: scs@eskimo.com (Steve Summit)
- Subject: Re: SIGBUS - What are the possible causes?
- X-Nntp-Posting-Host: eskimo.com
- Message-ID: <DKzFzF.IpK@eskimo.com>
- Sender: news@eskimo.com (News User Id)
- Organization: schmorganization
- References: <4ct4es$3k7@news1.wolfe.net>
- Date: Wed, 10 Jan 1996 20:38:02 GMT
-
- [nonexistent group comp.unix.programming deleted]
-
- In article <4ct4es$3k7@news1.wolfe.net>, mcguire@wolfe.net (McGuire) writes:
- > I am trying to compile a program under gcc 2.7.0 that works under the
- > native HP-UX 9.05 cc. In one routine I get a SIGBUS error... Does
- > anyone have any ideas as to what the possible causes of such an error
- > might be.
-
- Here's the comp.lang.c answer, from an extended version of
- the comp.lang.c FAQ list (now available from Addison-Wesley,
- ISBN 0-201-84519-9):
-
- 16.8: What do "Segmentation violation" and "Bus error" mean? What's a
- "core dump"?
-
- A: These symptoms (and any similar messages having to do with
- memory access violations or protection faults) generally mean
- that your program tried to access memory it shouldn't have,
- invariably as a result of improper pointer use. Likely causes
- are:
-
- inadvertent use of null pointers (see also questions 5.2
- and 5.20)
-
- uninitialized, misaligned, or otherwise improperly
- allocated pointers (see questions 7.1, 7.2, and 16.7)
-
- stale aliases to memory that has been relocated (see
- question 7.29)
-
- corruption of the malloc arena (see question 7.19)
-
- attempts to modify read-only values (those declared const,
- and string literals -- see question 1.32)
-
- mismatched function arguments, especially involving
- pointers; two possibilities are scanf() (see question
- 12.12) and fprintf() (make sure it receives its first
- FILE * argument)
-
- Under Unix, any of these problems almost invariably leads to a
- "core dump": a file named core, [1] created in the current
- directory, containing a memory image of the crashed process, for
- debugging.
-
- The distinction between "Bus error" and "Segmentation Violation"
- may or may not be significant; different versions of Unix
- generate these signals under different sets of circumstances.
- Roughly speaking, a segmentation violation indicates an attempt
- to access memory which doesn't even exist, and a bus error
- indicates an attempt to access memory in an illegal way (perhaps
- due to an unaligned pointer; see question 16.7).
-
- See also questions 16.3 and 16.4.
-
- __________
- 1. Yes, the name "core" derives ultimately from old ferrite core
- memories.
-
- Steve Summit
- scs@eskimo.com
-